package com.example.helloworld

import android.content.ContentValues.TAG
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView

class SecondActivity : AppCompatActivity() {

    val pics = arrayListOf<Pictures>()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_second)

        initData()

        val recycler = findViewById<RecyclerView>(R.id.recycler)
        recycler.layoutManager = LinearLayoutManager(this)
        recycler.adapter = PicAdapter(pics)

    }



    private fun initData() {

        for (i in 0..10){
            pics.add(Pictures().apply {
                uploader = "MoonRain"
                name = "grass_MoonRain"
                description = "绿色 清新 护眼 实拍 手机壁纸 草"
                avatar = R.mipmap.grass_moonrain
            })


        pics.add(Pictures().apply {
            uploader = "MoonRain"
            name = "cutegirl_MoonRain"
            description = "可爱 少女 动画 人物 漫画 电脑壁纸"
            avatar = R.mipmap.cutegirl_moonrain
        })

        pics.add(Pictures().apply {
            uploader = "MoonRain"
            name = "lanterns_MoonRain"
            description = "写意 意境 清新 灯笼 天空 漫画 手机壁纸"
            avatar = R.mipmap.lanterns_moonrain
        })

    }
    }

    fun onClick(view: View) {
        Log.i(TAG,"onClick ${view.id}")
        when(view.id) {
            R.id.to_tablayout -> {
                val intent = Intent(this, TablayoutActivity::class.java)
                startActivity(intent)
            }
        }
    }
}